<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
      <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
            border: 0;
            list-style: none;
        }
    </style>
</head>
<body>

    <input type='checkbox'  name='checkname' value='1' />value1  
    <input type='checkbox'  name='checkname' value='2' />value2 
    <input type='checkbox'  name='checkname' value='3' />value3 
    <input type='checkbox'  name='checkname' value='4' />value4
    <input type='checkbox'  name='checkname' value='5' />value5 
    <br><br><br>
    <input type="checkbox" name="" id="selectAll">全选
    <button type="" id="btn">提交</button>
    <script>
        $("#selectAll").click(function () {
            if(this.checked){
                $("input[name='checkname']").prop('checked',true);
                this.checked = true;

            }else{
                $("input[name='checkname']").prop('checked',false);
                this.checked = false;
            }
        })
       
        
        $("#btn").click(function () {
            var arr =[];
            $("input[name='checkname']:checkbox:checked").each(function () {
                var temp =$(this).val();
                arr.push(temp);
                return arr;
            }) 
             console.log(arr);
        })
   
    </script>
</body>
</html>